import 'package:flutter_app/datas/category_data.dart';
import 'package:flutter_app/datas/drama_data.dart';
import 'package:flutter_app/dio_client.dart';

class ApiService {
  final DioClient _dioClient = DioClient();

  Future<CategoryData?> getCategoryData() async {
    try {
      final response = await _dioClient.get("/category/creategory/app/all");
      if (response.statusCode == 200) {
        return CategoryData.fromJson(response.data);
      } else {
        throw Exception('Failed to load categories');
      }
    } catch (e) {
      print(e);
      return null;
    }
  }

  Future<DramaData?> getDramaData(id) async {
    try {
      final response = await _dioClient.get("/app/drama/app/get_drama_list?id=" + id);
      if (response.statusCode == 200) {
        return DramaData.fromJson(response.data);
      } else {
        throw Exception('Failed to load categories');
      }
    } catch (e) {
      print(e);
      return null;
    }
  }
}
